home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 07 - 1991 / 07.05 May 91 / Math Parser ƒ / ParserProcs / Eval next >
Encoding:
Text File  |  1990-10-04  |  1.3 KB  |  75 lines  |  [TEXT/PJMM]

  1. unit Eval;
  2.  
  3.  
  4. interface
  5.  
  6.  
  7.     uses
  8.         ParserGlobals, Operations, LexicalAnalysis, Parser, SetValues, EvaluateNodes, CheckLine;
  9.  
  10.  
  11.     function eval (var line: str255): str255;
  12.  
  13.  
  14. implementation
  15.  
  16.  
  17.     function eval;
  18.  
  19.  
  20.         label
  21.             999;
  22.  
  23.         var
  24.             removeblanks: boolean;
  25.             ntot, numnodes: integer;
  26.             sy, tokentype, ty, tytokentype: hdlstringarray0;
  27.             pr: hdlintarray0;
  28.             t: hdlextendarray;
  29.  
  30.     begin
  31.  
  32.         sy := hdlstringarray0(NewHandle(SizeOf(stringarray0)));
  33.         ty := hdlstringarray0(NewHandle(SizeOf(stringarray0)));
  34.         tokentype := hdlstringarray0(NewHandle(SizeOf(stringarray0)));
  35.         tytokentype := hdlstringarray0(NewHandle(SizeOf(stringarray0)));
  36.         pr := hdlintarray0(NewHandle(SizeOf(intarray0)));
  37.         t := hdlextendarray(NewHandle(SizeOf(extendarray)));
  38.  
  39.         removeblanks := true;
  40.         lexicalanalysis(line, removeblanks, ntot, sy, tokentype, pr, error);
  41.  
  42.         if error <> '' then
  43.             begin
  44.                 eval := error;
  45.                 goto 999;
  46.             end;
  47.  
  48.         checkline(ntot, sy, tokentype, pr, numnodes, t, error);
  49.  
  50.         if error <> '' then
  51.             begin
  52.                 eval := error;
  53.                 goto 999;
  54.             end;
  55.  
  56.         if numnodes <= 0 then
  57.             begin
  58.                 eval := '';
  59.                 goto 999;
  60.             end;
  61.  
  62.         eval := stringof(t^^[numnodes] : decplaceplus10 : decplace);
  63.  
  64.         DisposHandle(handle(sy));
  65.         DisposHandle(handle(ty));
  66.         DisposHandle(handle(tokentype));
  67.         DisposHandle(handle(tytokentype));
  68.         DisposHandle(handle(pr));
  69.         DisposHandle(handle(t));
  70.  
  71.  
  72. 999:
  73.     end;
  74.  
  75. end.